import logging

import pytest
from common.login_token import login_token
from common.assert_tools import assert_tools
from common.dbTools import DBtool
from config import BASE_PATH, TEL
from api.emp_manage_api import AddEmp
from common.rea_json import read_emp_json



class TestAddEmp(object):
    def setup(self, ):
        self.add=AddEmp()
        self.token_data=login_token()
        print("-------------------------开始-------------------------------")
        DBtool.db_idu(f"delete from bs_user where mobile = '{TEL}';")

    def teardown(self):
        DBtool.db_idu(f"delete from bs_user where mobile = '{TEL}';")
        print("-------------------------结束--------------------------------")
    filename = BASE_PATH + "/data/add_emp_data.json"
    data = read_emp_json(filename)
    @pytest.mark.parametrize("dectsc,req_body,sratus_code,success,code,message",data)
    def test_add_emp(self,dectsc,req_body,sratus_code,success,code,message):

        resp=self.add.add_emp(self.token_data,req_body)
        # print(dectsc,resp.json())
        #日志输出
        logging.info(f"这是晚自习作业题的日志信息 {dectsc}:{resp.json()}")

        assert_tools(resp,sratus_code,success,code,message)

